<template>
    <!--父传子  直接赋值-->
    <!-- <Product title="开封灌汤包" price="28" intro="开业大酬宾，全场不要钱"></Product>
    <Product title="沪上阿姨" price="15" intro="阿姨不在，全场1折"></Product>
     <Product title="中牟花生" price="3" intro="伯伯不在，全地随便挖，逮到算他的"></Product> -->
        <Product v-for="(item, index ) in list" :key="item.id"
                :title="item.title" :price="item.price"
                :intro="item.intro" 
                :index="index"
                @subprice="fn"></Product>
         <!-- <Product v-for="item in list" :key="item.id"
                   :obj="item"></Product>  -->
    </template>
<script>
import Product from './Product.vue'
export default {
    data() {
        return {
            list: [
                { id: 1, title: "开封灌汤包", price: "28", intro: "开业大酬宾，全场不要钱" },
                { id: 2, title: "沪上阿姨", price: "15", intro: "阿姨不在，全场1折" },
                { id: 3, title: "中牟花生", price: "3", intro: "伯伯不在，全地随便挖，逮到算他的" },
            ]
            
      }  
    },
    components: {
        Product
    }, methods: {
        fn(index, price) { 
            console.log(index,"===",price);
        //     this.list[index].price = (this.list[index].price - price).toFixed(2)
        //  console.log(this.list[index].price);
      this.list[index].price > 1 && (this.list[index].price = (this.list[index].price - price).toFixed(2))
        }
    }
}


</script>